package Crawler;

import redis.clients.jedis.Jedis;

import java.util.List;

public class IPTest {

    private static Jedis jedis = new Jedis("222.27.227.115", 6379);

    public static void main(String[] args) {

        // 从Redis中读取并出队
        // 用队列是一次全部取出
        System.out.println(jedis.lrange("weibo:ippool", 0, -1));
        List<String> list = jedis.lrange("weibo:ippool", 0, -1);
        for (int i = 0; i < list.size(); i++) {
            String line = list.get(i).toString();
            String[] parts = line.split(":");
            String ip = parts[0];
            String port = parts[1];
            System.getProperties().setProperty("http.proxyHost", ip);
            System.getProperties().setProperty("http.proxyPort", port);
            System.out.println("IP代理已就位......");
        }
    }
}
